if (window.plus) {
	ready();
} else {
	document.addEventListener('plusready', ready, false);
}

$(function() {
	if (AGENT_CLIENT.WEB) {
		ready();
	}
})

function ready() {
	var
		user = {},
		html = [],
		thisPage = {};

	barcodePage = function() {
		this.init();
	};
	barcodePage.prototype = {
		init: function() {
			this.initData();
			this.bindEvent();
		},
		initData: function() {
			var thisModel = this;
			user = getLocalStorage(STORAGE_MANAGER.user);
			if (!user || !(user.id > 0)) {
				redirect("login.html");
			}
			var inviteUrl = "http://wap.soolife.cn/view/account/register.html?memberid=" + user.id;  
			getBarImage($("#myBarcode"), inviteUrl);
		},
		bindEvent: function() {
			$("#back").on("click", function() {
				back();
			});
			//将图片保存到手机		
			if (AGENT_CLIENT.APP) {				
				$("#myBarcode").longPress(function(){
					$.confirm("保存到相册?", function (e) {
	                    if (e.index == 0) {
	                    	var imageUrl = $("#myBarcode").attr("src");
	                    	console.log(imageUrl);
	                        saveGallery(imageUrl);
	                    }
                	}, "提示", ["是", "否"]);
				});
			}
		},
	};
	thisPage = new barcodePage();
}